/*
 * Copyright (C) 2009 Kristopher T Babic
 *
 * This program is free software; you can redistribute it and/or modify it under the terms of
 * the GNU General Public License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program;
 * if not, see <http://www.gnu.org/licenses>.
 */

package edu.idp.shared.compress;

import java.io.IOException;

/**
 * @author Kristopher T Babic
 */
abstract public class Compress {

    private String raw;
    private String compressed;
    private String decompressed;


    public void setRaw(String s) {
        raw = s;
    }

    protected void setCompressed(String s) {
        compressed = s;
    }

    protected void setDecompressed(String s) {
        decompressed = s;
    }

    public String getRaw() {
        return raw;
    }

    public String getCompressed() {
        return compressed;
    }

    public String getDecompressed() {
        return decompressed;
    }

    public Compress() {
        this(null);
    }

    public Compress(String data) {
        setRaw(data);
        setCompressed(null);
        setDecompressed(null);
    }

    public void compress(String data) throws IOException {
        setRaw(data);
        compress();
    }

    public void decompress(String data) throws IOException {
        setRaw(data);
        decompress();
    }

    abstract public void compress() throws IOException;

    abstract public void decompress() throws IOException;

    public boolean equals(String s) {
        return s.equals(compressed);
    }
}